package com.sgb.kjwl.viewmodel.material;

import androidx.databinding.ObservableField;

import com.sgb.kjwl.AppConstant;
import com.sgb.kjwl.model.entity.supplier3.DictEntity3;
import com.sgb.kjwl.repository.MaterialRepertory;
import com.sgb.kjwl.view.ui.fragment.material.AllMaterialListFragment3;
import com.swgk.core.base.BaseViewModel;
import com.swgk.core.base.model.entity.BaseEntity;
import com.swgk.core.util.MLog;

import java.util.List;

import io.reactivex.functions.Consumer;

public class AllGoodsMaterialListModel3 extends BaseViewModel {
    public ObservableField<String> areaCode = new ObservableField<>("");
    private AllMaterialListFragment3 fragment;
    private MaterialRepertory repertory;

    public AllGoodsMaterialListModel3(AllMaterialListFragment3 fragment, MaterialRepertory repertory) {
        this.fragment = fragment;
        this.repertory = repertory;
        areaCode.set(repertory.getAreaCode());
    }

    public String getAreaNameModel() {
        return repertory.getAreaName();
    }

    public String getAreaCodeModel() {
        return repertory.getAreaCode();
    }


    public void getFilterTypeModel(String id,boolean isRefresh) {
        repertory.getMaterialFilterType(id, areaCode.get()).subscribe(listBaseEntity -> {
                    if (listBaseEntity.getState().equals(AppConstant.REQEUST_SECCUESS)) {
                        fragment.showTypeView(listBaseEntity.getData(),isRefresh);
                    }
                }, throwable -> MLog.d(AppConstant.API_LOG, "error " + throwable.getMessage()));
    }
}
